
package GUI;

import Arbori.*;
import Visitor.*;

public class DerivareField implements Command{
    private ArboreFunctional a;
    private ArboreFunctional stareA;
    private String stareText;
    private javax.swing.JTextField textDerivare;

    public DerivareField(ArboreFunctional a,javax.swing.JTextField td){
        this.a = a;
        this.textDerivare = td;
    }

    public ArboreFunctional execute(){
        getStare();
        Visitor derivVisitor = new DerivareVisitor();
        a.acceptVisitor(derivVisitor);
        textDerivare.setText(((DerivareVisitor)derivVisitor).getS());
        return a;
    }

    public String getErr(){
        return "";
    }

    public void getStare(){
        this.stareA = a;
        this.stareText = textDerivare.getText();
    }

    public ArboreFunctional unexecute(){
        this.a = stareA;
        textDerivare.setText(stareText);
        return a;
    }
    public void update(ArboreFunctional af){
        this.a = af;
    }
}
